#!/bin/bash
set -e;
echo "check system"
case $(uname -m) in
    x86_64)  deploy_sys=5.2.0_amd64;;
    aarch64) deploy_sys=5.1.0_rapi_aarch64;;
	*) echo "scripts not support system `uname -m`"&&exit ;;
esac


random_mac=`ip a|grep link/ether|awk '{print$2}'|head -1|xargs echo -n`



cd /tmp/;
rm -f phddns_${deploy_sys}.deb;

echo "download phddns";
wget "https://dl.oray.com/hsk/linux/phddns_${deploy_sys}.deb" -O phddns_${deploy_sys}.deb


echo "begin uninstall phddns";
if [  `phddns`];then
	sudo dpkg -r phddns;

fi


echo "begin install phddns "
sudo dpkg -i phddns_${deploy_sys}.deb
sudo phddns start;
sudo phddns enable;
phddns status;

